package controller

import (
	appsv1 "k8s.io/api/apps/v1"
	corev1 "k8s.io/api/core/v1"
	nwv1 "k8s.io/api/networking/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/types"
)

type Jsonpoddata struct {
	Metadata Podmetadatastruct  `json:"metadata,omitempty"`
	Spec     corev1.PodSpec     `json:"spec,omitempty"`
	Status   corev1.PodStatus   `json:"status,omitempty"`
}
type Podmetadatastruct struct {
	Name                      string                      `json:"name"`
	GenerateName              string                      `json:"generateName"`
	Namespace                 string                      `json:"namespace"`
	Uid                       types.UID                   `json:"uid"`
	ResourceVersion           string                      `json:"resourceVersion"`
	Labels                    map[string]string           `json:"labels,omitempty"`
	Annotations               map[string]string           `json:"annotations,omitempty"`
	OwnerReferences           []metav1.OwnerReference     `json:"ownerReferences,omitempty"`
	Finalizers                []string                    `json:"finalizers,omitempty"`
	ZZZ_DeprecatedClusterName string                      `json:"clusterName,omitempty"`
	ManagedFields             []metav1.ManagedFieldsEntry `json:"-"`
}


type Objectstruct struct {
	Name                       string                      `json:"name"`
	GenerateName               string                      `json:"-"`
	Namespace                  string                      `json:"namespace"`
	SelfLink                   string                      `json:"selfLink,omitempty"`
	Uid                        types.UID                   `json:"uid"`
	ResourceVersion            string                      `json:"resourceVersion"`
	Generation                 int64                       `json:"generation,omitempty"`
	CreationTimestamp          metav1.Time                 `json:"creationTimestamp,omitempty"`
	DeletionTimestamp          *metav1.Time                `json:"deletionTimestamp,omitempty"`
	DeletionGracePeriodSeconds *int64                      `json:"deletionGracePeriodSeconds,omitempty"`
	Labels                     map[string]string           `json:"labels,omitempty"`
	Annotations                map[string]string           `json:"annotations,omitempty"`
	OwnerReferences            []metav1.OwnerReference     `json:"ownerReferences,omitempty"`
	Finalizers                 []string                    `json:"finalizers,omitempty"`
	ZZZ_DeprecatedClusterName  string                      `json:"clusterName,omitempty"`
	ManagedFields              []metav1.ManagedFieldsEntry `json:"-"`
}

type Jsondeploydata struct {
	// 解释一下为什么后面要加上	`json:"metadata"`字段，如果不加的话，返回给前端的yaml文件中，metadata变为了大写的Metadata关键字，这样子是错误的了，导致修改yaml会报"resource name may not be empty"的错误.
	// omitempty的意思是如果这条消息没有提供，在序列化成json的时候就不要包含其默认值
	Metadata Objectstruct	`json:"metadata,omitempty"`
	Spec     appsv1.DeploymentSpec   `json:"spec,omitempty"`
	Status   appsv1.DeploymentStatus `json:"status,omitempty"`
}


//type deploymetadatastruct struct {
//	deploymetadatastruct objectstruct
//}


type Jsonservicedata struct {
	Metadata Objectstruct 	`json:"metadata,omitempty"`
	Spec corev1.ServiceSpec 	`json:"spec,omitempty"`
	Status corev1.ServiceStatus `json:"status,omitempty"`
}

//type servicedatastruct struct {
//
//}

type Jsonnodedata struct {
	Metadata Objectstruct 	`json:"metadata,omitempty"`
	Spec corev1.NodeSpec 	`json:"spec,omitempty"`
	Status corev1.NodeStatus `json:"status,omitempty"`
}

//type nodedatastruct struct {
//
//}

type Jsonnamespacedata struct {
	Metadata Objectstruct 	`json:"metadata,omitempty"`
	Spec corev1.NamespaceSpec 	`json:"spec,omitempty"`
	Status corev1.NamespaceStatus `json:"status,omitempty"`
}

type Jsoningressdata struct {
	Metadata Objectstruct 	`json:"metadata,omitempty"`
	Spec nwv1.IngressSpec 	`json:"spec,omitempty"`
	Status nwv1.IngressStatus `json:"status,omitempty"`
}